import type { Address, ExpressData, MedicalOrderDetail, OrderListData, orderListData, OrderQuery, preOrderParams } from '@/type/order'
import request from '@/utils/request'

// 地址
export const getAddressAPI = () => {
  return request.get<null, Address>('/patient/order/address')
}

// 预支付订单
export const preOrderAPI = (prescriptionId: string) => {
  return request.get<null, preOrderParams>('/patient/medicine/order/pre', {
    params: {
      prescriptionId,
    },
  })
}


/**
 * 药品待支付订单
 * id:处方 id
 * addressId: 地址id
 */
export const createOrderAPI = (id: string, addressId: string) => {
  return request.post<any, { id: string }>('/patient/medicine/order', { id, addressId })
}
// getMedicalOrderDetail
/** 支付结果的返回接口 */
export const getMedicalOrderDetailAPI=(id:string) => {
  return request.get<null,MedicalOrderDetail>(`/patient/medicine/order/detail/${id}`)
}


/**
 * 药品订单列表
 */
export const orderListApi = (status = 10, current = 1, pageSize = 10) => {
  return request.get<null,orderListData>('/patient/medicine/order/mylist', {
    params: { status, current, pageSize },
  })
}


/**
 * 医生问诊列表
 */
export const getOrderListApi = (data:OrderQuery) => {
  return request.get<null, OrderListData>('/patient/consult/order/list', { params: data })
}

// 获取药品订单物流信息
export const getMedicalOrderLogistics = (id: string) => {
  return  request.get<null, ExpressData>(`/patient/order/${id}/logistics`)
}